const { langChoies } = require("../config");
const inquirer = require("inquirer");
const config = require("../mfo.config.js");

module.exports = (context, callback) => {
  if (process.env.LANGUAGE) {
    context.lang = process.env.LANGUAGE;
    return Promise.resolve(callback(context));
  } else {
    const langs = langChoies();
    return inquirer
      .prompt([
        {
          name: "projectDict",
          message: "Language ?",
          default: config.language.default || "english",
          pageSize: langs.length + 2,
          type: "rawlist",
          choices: [...langs],
        },
      ])
      .then((answers) => {
        context.lang = answers.projectDict;
        return callback(context);
      });
  }
};
